//
//  ZHShowStatisticsMegView.m
//  Doctor
//
//  Created by liuzhishan on 15/12/29.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHShowStatisticsMegView.h"
#define CENTERWIDTH  (200*WIDPro)

#define LABLEGAP  (5*WIDPro)
@interface ZHShowStatisticsMegView ()

@property (strong, nonatomic)  UILabel *leftLable;
@property (strong, nonatomic)  UILabel *centerLable;
@property (strong, nonatomic)  UILabel *rightLable;
@property (strong ,nonatomic) UIImageView *bgImageView;

@end

@implementation ZHShowStatisticsMegView


-(void)setMyBgAlpha:(CGFloat)count
{
    self.bgImageView.alpha = count;
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addChildViews];
        
    }
    return self;
}

-(void)setbgImageName:(NSString*)name
{
    self.bgImageView.image = [UIImage imageNamed:name];
}

-(void)addChildViews
{
    
    self.bgImageView = [[UIImageView alloc]init];
    self.bgImageView.backgroundColor = [UIColor whiteColor];
    self.bgImageView.translatesAutoresizingMaskIntoConstraints = NO;
    
    [self addSubview:self.bgImageView];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.bgImageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.bgImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.bgImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.bgImageView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];
   
    
    
    self.centerLable = [[UILabel alloc]init];
    self.centerLable.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:self.centerLable];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.centerLable attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationLessThanOrEqual toItem:nil attribute:NSLayoutAttributeWidth multiplier:1.0 constant:CENTERWIDTH]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.centerLable attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
    
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.centerLable attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
    
   
    
    self.leftLable = [[UILabel alloc]init];
    self.leftLable.textAlignment = NSTextAlignmentRight;
    self.leftLable.translatesAutoresizingMaskIntoConstraints = NO;
    
    [self addSubview:self.leftLable];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.leftLable attribute:NSLayoutAttributeRight relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeLeft) multiplier:1.0 constant:-LABLEGAP]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.leftLable attribute:(NSLayoutAttributeCenterY) relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeCenterY) multiplier:1.0 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.leftLable attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]];
    
    
   
    
    self.rightLable = [[UILabel alloc]init];
    self.rightLable.translatesAutoresizingMaskIntoConstraints = NO;
    
    [self addSubview:self.rightLable];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.rightLable attribute:(NSLayoutAttributeLeft) relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeRight) multiplier:1.0 constant:LABLEGAP]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.rightLable attribute:(NSLayoutAttributeCenterY) relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeCenterY) multiplier:1.0 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.rightLable attribute:(NSLayoutAttributeRight) relatedBy:(NSLayoutRelationLessThanOrEqual) toItem:self attribute:(NSLayoutAttributeRight) multiplier:1.0 constant: -LABLEGAP]];
    
   
    
    self.centerLable.textColor = [UIColor grayColor];
    self.leftLable.textColor = [UIColor grayColor];
    self.rightLable.textColor = [UIColor grayColor];
    
    self.centerLable.font = [UIFont systemFontOfSize:18*WIDPro - 2];
    self.leftLable .font = [UIFont systemFontOfSize:18*WIDPro - 2];
    self.rightLable.font = [UIFont systemFontOfSize:18*WIDPro - 2];
    
    
    
    
}

-(void)setNotAppointArriveCount:(NSInteger )notAppointArrive andAppointArriveCount:(NSInteger)AppointArrive andAppointNotArriveCount:(NSInteger)AppointNotArrive{
    
    self.centerLable.text = [NSString stringWithFormat:@"预约到店:%ld",AppointArrive];
    [self.centerLable sizeToFit];
    self.leftLable.text = [NSString stringWithFormat:@"未预约到店:%ld",notAppointArrive];
    [self.leftLable sizeToFit];
    self.rightLable.text = [NSString stringWithFormat:@"预约未到店:%ld",AppointNotArrive];
    [self.rightLable sizeToFit];
    
}


@end
